// src/router/index.js
import {createRouter, createWebHistory} from 'vue-router';
import Login from '@/views/Login.vue';
import Homepage from '@/views/Homepage.vue';
import Register from "@/views/Register.vue";
import Main from "@/views/Main.vue";
import MyAccount from '@/views/Main/UserCenter/MyAccount.vue'
import All from "@/views/Main/GoodList/All.vue";
import Commodity from "@/views/Main/GoodList/Commodity.vue";
import Food from "@/views/Main/GoodList/Food.vue";
import Electronics from "@/views/Main/GoodList/Electronics.vue";
import Clothing from "@/views/Main/GoodList/Clothing.vue";
import Beauty from "@/views/Main/GoodList/Beauty.vue";
import Others from "@/views/Main/GoodList/Others.vue";
import MyFavoritesAll from "@/views/Main/MyFavorites/MyFavoritesAll.vue";
import MyFavoritesBeauty from "@/views/Main/MyFavorites/MyFavoritesBeauty.vue";
import MyFavoritesClothing from "@/views/Main/MyFavorites/MyFavoritesClothing.vue";
import MyFavoritesCommodity from "@/views/Main/MyFavorites/MyFavoritesCommodity.vue";
import MyFavoritesElectronics from "@/views/Main/MyFavorites/MyFavoritesElectronics.vue";
import MyFavoritesFood from "@/views/Main/MyFavorites/MyFavoritesFood.vue";
import MyFavoritesOthers from "@/views/Main/MyFavorites/MyFavoritesOthers.vue";

const routes = [
    // 默认路径
    {
        path: '/',
        redirect: '/Homepage'
    },
    // 首页
    {
        path: '/Homepage',
        name: 'Homepage',
        component: Homepage
    },
    // 登录
    {
        path: '/Login',
        name: 'Login',
        component: Login
    },
    // 注册
    {
        path: '/Register',
        name: 'Register',
        component: Register
    },
    // 主要页面
    {
        path: '/Main',
        name: 'Main',
        component: Main,
        redirect: '/Main/goodsList/All',
        children: [
            /*
            * 用户中心
            */
            {
                path: 'userCenter', name: 'UserCenter', redirect: '/Main/userCenter/myAccount',
                children: [
                    {
                        path: 'myAccount', name: 'MyAccount', component: MyAccount
                    }
                ]
            },
            /*
            * 商品列表
            */
            {
                path: 'goodsList', name: 'GoodsList', redirect: '/Main/goodsList/All',
                children: [
                    //全部
                    {
                        path: 'All', name: 'All', component: All
                    },
                    //日用类
                    {
                        path: 'Commodity', name: 'Commodity', component: Commodity
                    },
                    //食品类
                    {
                        path: 'Food', name: 'Food', component: Food
                    },
                    //电子类
                    {
                        path: 'Electronics', name: 'Electronics', component: Electronics
                    },
                    //服装类
                    {
                        path: 'Clothing', name: 'Clothing', component: Clothing
                    },
                    //美妆类
                    {
                        path: 'Beauty', name: 'Beauty', component: Beauty
                    },
                    //其他类
                    {
                        path: 'Others', name: 'Others', component: Others
                    }
                ]
            },
            /*
            * 收藏夹
            */
            {
                path: 'myFavorites', name: 'MyFavorites', redirect: '/Main/myFavorites/All',
                children: [
                    //全部
                    {
                        path: 'MyFavoritesAll', name: 'MyFavoritesAll', component: MyFavoritesAll
                    },
                    {
                        path: 'MyFavoritesBeauty', name: 'MyFavoritesBeauty', component: MyFavoritesBeauty
                    },
                    {
                        path: 'MyFavoritesClothing', name: 'MyFavoritesClothing', component: MyFavoritesClothing
                    },
                    {
                        path: 'MyFavoritesCommodity', name: 'MyFavoritesCommodity', component: MyFavoritesCommodity
                    },
                    {
                        path: 'MyFavoritesElectronics',
                        name: 'MyFavoritesElectronics',
                        component: MyFavoritesElectronics
                    },
                    {
                        path: 'MyFavoritesFood', name: 'MyFavoritesFood', component: MyFavoritesFood
                    },
                    {
                        path: 'MyFavoritesOthers', name: 'MyFavoritesOthers', component: MyFavoritesOthers
                    },
                ]
            }

        ]
    }
];

const router = createRouter({
    history: createWebHistory(),
    routes
});

export default router;
